<?

require_once "config/config.php";
require_once "baseclasses.php";

$PARAPARA = init_paraforum();

function init_paraforum() {
    global $PARA_CONFIG;
    global $PARA_PRE_SETUP;

    // Initialize config
    $config  = new Config( $PARA_CONFIG );

    // Create DB link qua a DBLayer object
    $dblayer = new DBLayer( $config );

    if(!$dblayer->is_up) {
        throw new Exception("DB connection failed :" . $dblayer->error_message );
    }

    if(!$PARA_PRE_SETUP)
        $dblayer->read_config( );

    $parapara = new ParaPara( $config, $dblayer );

    // Parse auth cookie
    $auth_cookie = $_COOKIE['ParaSite_Auth'];
    if( $auth_cookie ) {
        $cookie_status = $parapara->parse_auth_cookie( $auth_cookie );
    }


    return $parapara;
}

?>